<template>
  <div class="app-container">
    <label class="title"
           style="font-size: 20px;color: rgba(0,0,0,.85);font-weight: 600;line-height: 32px">考试异议日志</label>

    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="异议类型" prop="objectionType">
        <el-select v-model="queryParams.objectionType" placeholder="全部" clearable size="small">
          <el-option
            v-for="dict in dict.type.specialTypes"
            :key="dict.value"
            :label="dict.raw.remark"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="关键字" prop="main">
        <el-input
          v-model="queryParams.main"
          placeholder="准考证、考生姓名、考试项目"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="examObjection">
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{scope.$index+(queryParams.pageNo-1)*queryParams.pageSize+1}}</span>
        </template>
      </el-table-column>

      <el-table-column label="准考证" align="center" prop="zkh"/>
      <el-table-column label="姓名" align="center" prop="ksName"/>
      <el-table-column label="考试项目" align="center" prop="examName"/>
      <el-table-column label="异议类型" align="center" prop="objectionType">
        <template slot-scope="scope">
          <dict-tag-remark :options="dict.type.specialTypes" :value="scope.row.objectionType"/>
        </template>
      </el-table-column>
      <el-table-column label="之前结果" align="center" prop="beforeResult"/>
      <el-table-column label="改后结果" align="center" prop="afterResult"/>
      <el-table-column label="原因" align="center" prop="reason"/>
      <el-table-column label="处理人" align="center" prop="handler"/>
      <el-table-column label="处理日期" align="center" prop="handlerDate">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.handlerDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:examObjection:edit']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>
<script>
  import { del, list } from '@/api/business/examObjection/examObjection'

  export default {
    name: 'examObjection',
    dicts: ['specialTypes'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 考试异议日志表格数据
        examObjection: [],
        // 弹出层标题
        title: '',
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNo: 1,
          pageSize: 10,
          main: null,
          objectionType: null
        }
      }
    },
    created() {
      this.getList()
    },
    methods: {
      getList() {
        this.loading = true
        list(this.queryParams).then(response => {
          this.examObjection = response.data.records
          this.total = response.data.totalCount
          this.loading = false
        })
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNo = 1
        this.getList()
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm('queryForm')
        this.handleQuery()
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        this.$modal.confirm('确定删除吗？').then(function() {
          return del(row.id)
        }).then(() => {
          this.getList()
          this.$modal.msgSuccess('删除成功')
        }).catch(() => {
        })
      }
    }
  }
</script>
